/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 *
 * Created on 2009. 1. 23, 오후 9:00:23
 */

package com.jay.gui;

import com.jay.database.DatabaseConnection;
import com.jay.operation.Executer;
import com.jay.util.CommonConst;
import com.jay.util.CommonLnFConst;
import com.jay.util.CommonUtil;
import com.jay.util.FileLoader;
import com.jay.util.FileSaver;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dialog;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.print.PrinterException;
import java.beans.PropertyChangeEvent;
import java.beans.PropertyChangeListener;
import java.io.File;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.StringTokenizer;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.ImageIcon;
import javax.swing.JEditorPane;
import javax.swing.JFileChooser;
import javax.swing.JOptionPane;
import javax.swing.JProgressBar;
import javax.swing.JSplitPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.SwingWorker;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.table.DefaultTableModel;
import javax.swing.text.BadLocationException;
import javax.swing.text.PlainDocument;
import javax.swing.undo.UndoManager;
/**
 *
 * @author jay
 */
public class JayFrame extends javax.swing.JFrame implements ActionListener,
    PropertyChangeListener{
    String mCommonInput = null;
    ConnectDialogBean cdb = null;
    CommonUtil cu = new CommonUtil();
    JProgressBar jb = null;
    ImageIcon icon = null;
    
    public void insertEditBean(String aText){
        try {
            ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent()).insertText(aText);
        } catch (BadLocationException ex) {
            ed.viewExceptionDialog(ex);
        }
    }
    
    public void setTextBean(String aText) {
        ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent()).getEditorPane().setText(aText);
    }

    /** Creates new form JayFrame1 */
    public JayFrame() {
        initComponents();
        ImageIcon icon = new ImageIcon(CommonConst.ARARE_PNG_PATH);
        this.setIconImage(icon.getImage());

        this.editBean1.setJayFrame(this);
        this.treeBean1.setFrame(this);
        um = new UndoManager();
        this.editBean1.getEditorPane().getDocument().addUndoableEditListener(um);
        
        ed = new ExceptionDialog(this); 
        
        jb = this.messageBean1.getJProgressBar();
        
        this.jSplitPane1.setDividerLocation(300);
        this.jSplitPane2.setDividerLocation(300);
        this.jSplitPane3.setDividerLocation(500);
        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jFileChooser1 = new javax.swing.JFileChooser();
        tabPopupMenu = new javax.swing.JPopupMenu();
        closeTabMenu = new javax.swing.JMenuItem();
        jSeparator13 = new javax.swing.JPopupMenu.Separator();
        undoTabMenu = new javax.swing.JMenuItem();
        redoTabMenu = new javax.swing.JMenuItem();
        jSeparator17 = new javax.swing.JPopupMenu.Separator();
        cutTabMenu = new javax.swing.JMenuItem();
        copyTabMenu = new javax.swing.JMenuItem();
        pasteTabMenu = new javax.swing.JMenuItem();
        selectAllTabMenu = new javax.swing.JMenuItem();
        jSeparator18 = new javax.swing.JPopupMenu.Separator();
        findTabMenu = new javax.swing.JMenuItem();
        findTabNextMenu = new javax.swing.JMenuItem();
        replaceTabMenu = new javax.swing.JMenuItem();
        jSeparator20 = new javax.swing.JPopupMenu.Separator();
        commentOutTabMenu = new javax.swing.JMenuItem();
        uncommentTabMenu = new javax.swing.JMenuItem();
        jSeparator21 = new javax.swing.JPopupMenu.Separator();
        toggleCaseTabMenu = new javax.swing.JMenuItem();
        jSeparator22 = new javax.swing.JPopupMenu.Separator();
        removeTabMenu = new javax.swing.JMenuItem();
        jPanel1 = new javax.swing.JPanel();
        jSplitPane1 = new javax.swing.JSplitPane();
        jTabbedPane1 = new javax.swing.JTabbedPane();
        jSplitPane2 = new javax.swing.JSplitPane();
        cellBean1 = new com.jay.gui.CellBean();
        editBean1 = new com.jay.gui.EditBean();
        jSplitPane3 = new javax.swing.JSplitPane();
        treeBean1 = new com.jay.gui.TreeBean();
        cellBean2 = new com.jay.gui.CellBean();
        jPanel2 = new javax.swing.JPanel();
        messageBean1 = new com.jay.gui.MessageBean();
        jToolBar1 = new javax.swing.JToolBar();
        newButton = new javax.swing.JButton();
        openButton = new javax.swing.JButton();
        saveButton = new javax.swing.JButton();
        saveAsButton = new javax.swing.JButton();
        jSeparator1 = new javax.swing.JToolBar.Separator();
        previewButton = new javax.swing.JButton();
        printButton = new javax.swing.JButton();
        jSeparator2 = new javax.swing.JToolBar.Separator();
        cutButton = new javax.swing.JButton();
        copyButton = new javax.swing.JButton();
        pasteButton = new javax.swing.JButton();
        jSeparator3 = new javax.swing.JToolBar.Separator();
        undoButton = new javax.swing.JButton();
        redoButton = new javax.swing.JButton();
        jSeparator4 = new javax.swing.JToolBar.Separator();
        connectButton = new javax.swing.JButton();
        disconnectButton = new javax.swing.JButton();
        jSeparator16 = new javax.swing.JToolBar.Separator();
        runButton = new javax.swing.JButton();
        viewObjectButton = new javax.swing.JButton();
        jSeparator5 = new javax.swing.JToolBar.Separator();
        commitButton = new javax.swing.JButton();
        rollbackButton = new javax.swing.JButton();
        jSeparator6 = new javax.swing.JToolBar.Separator();
        cancelButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        FileMenu = new javax.swing.JMenu();
        NewFileSubMenu = new javax.swing.JMenu();
        NewEmptyTabItem = new javax.swing.JMenuItem();
        ClearCurrentTabItem = new javax.swing.JMenuItem();
        OpenFileSubMenu = new javax.swing.JMenu();
        OpenFileIntoNewTabItem = new javax.swing.JMenuItem();
        OpenFileIntoCurrentTabItem = new javax.swing.JMenuItem();
        SaveItem = new javax.swing.JMenuItem();
        SaveAsItem = new javax.swing.JMenuItem();
        CloseTabItem = new javax.swing.JMenuItem();
        CloseAllTabItem = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JSeparator();
        LoginItem = new javax.swing.JMenuItem();
        DisconnectItem = new javax.swing.JMenuItem();
        jSeparator8 = new javax.swing.JSeparator();
        PreviewSubMenu = new javax.swing.JMenu();
        PrintPreviewSQLItem = new javax.swing.JMenuItem();
        PrintPreviewResultItem = new javax.swing.JMenuItem();
        PrintSubMenu = new javax.swing.JMenu();
        PrintSQLItem = new javax.swing.JMenuItem();
        PrintResultItem = new javax.swing.JMenuItem();
        jSeparator9 = new javax.swing.JSeparator();
        ExitItem = new javax.swing.JMenuItem();
        EditMenu = new javax.swing.JMenu();
        UndoItem = new javax.swing.JMenuItem();
        RedoItem = new javax.swing.JMenuItem();
        jSeparator10 = new javax.swing.JSeparator();
        CutItem = new javax.swing.JMenuItem();
        CopyItem = new javax.swing.JMenuItem();
        PasteItem = new javax.swing.JMenuItem();
        SelectAllItem = new javax.swing.JMenuItem();
        jSeparator11 = new javax.swing.JSeparator();
        FindItem = new javax.swing.JMenuItem();
        FindNextItem = new javax.swing.JMenuItem();
        ReplaceItem = new javax.swing.JMenuItem();
        jSeparator12 = new javax.swing.JSeparator();
        ToggleCaseItem = new javax.swing.JMenuItem();
        ScriptMenu = new javax.swing.JMenu();
        RunScriptItem = new javax.swing.JMenuItem();
        RunScriptCurrentPositionItem = new javax.swing.JMenuItem();
        jSeparator14 = new javax.swing.JSeparator();
        CommitItem = new javax.swing.JMenuItem();
        RollBackItem = new javax.swing.JMenuItem();
        ResultMenu = new javax.swing.JMenu();
        FindInResultItem = new javax.swing.JMenuItem();
        jSeparator15 = new javax.swing.JSeparator();
        ExportToExcelItem = new javax.swing.JMenuItem();
        ExportToCSVItem = new javax.swing.JMenuItem();
        ExportToXMLItem = new javax.swing.JMenuItem();
        ToolsMenu = new javax.swing.JMenu();
        DataImpExpItem = new javax.swing.JMenuItem();
        DataExpCurrentSQLItem = new javax.swing.JMenuItem();
        LookAndFeelMenu = new javax.swing.JMenu();
        NimbusMenu = new javax.swing.JMenuItem();
        WindowsMenu = new javax.swing.JMenuItem();
        MetalMenu = new javax.swing.JMenuItem();
        MotifMenu = new javax.swing.JMenuItem();
        MacMenu = new javax.swing.JMenuItem();
        KunstoffMenu = new javax.swing.JMenuItem();
        HelpMenu = new javax.swing.JMenu();
        AboutItem = new javax.swing.JMenuItem();

        closeTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.CTRL_MASK));
        closeTabMenu.setText("Close Tab");
        closeTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                closeTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(closeTabMenu);
        tabPopupMenu.add(jSeparator13);

        undoTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK));
        undoTabMenu.setText("Undo");
        undoTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                undoTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(undoTabMenu);

        redoTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        redoTabMenu.setText("Redo");
        redoTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                redoTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(redoTabMenu);
        tabPopupMenu.add(jSeparator17);

        cutTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        cutTabMenu.setText("Cut");
        cutTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cutTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(cutTabMenu);

        copyTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        copyTabMenu.setText("Copy");
        copyTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                copyTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(copyTabMenu);

        pasteTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
        pasteTabMenu.setText("Paste");
        pasteTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pasteTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(pasteTabMenu);

        selectAllTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        selectAllTabMenu.setText("Select All");
        selectAllTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                selectAllTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(selectAllTabMenu);
        tabPopupMenu.add(jSeparator18);

        findTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));
        findTabMenu.setText("Find");
        findTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                findTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(findTabMenu);

        findTabNextMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
        findTabNextMenu.setText("Find Next");
        findTabNextMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                findTabNextMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(findTabNextMenu);

        replaceTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
        replaceTabMenu.setText("Replace");
        replaceTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                replaceTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(replaceTabMenu);
        tabPopupMenu.add(jSeparator20);

        commentOutTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS, java.awt.event.InputEvent.CTRL_MASK));
        commentOutTabMenu.setText("Commnet Out Selected Lines");
        commentOutTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                commentOutTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(commentOutTabMenu);

        uncommentTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_MINUS, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        uncommentTabMenu.setText("Uncomment Selected Lines");
        uncommentTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                uncommentTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(uncommentTabMenu);
        tabPopupMenu.add(jSeparator21);

        toggleCaseTabMenu.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        toggleCaseTabMenu.setText("Toggle Case Of Selection");
        toggleCaseTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                toggleCaseTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(toggleCaseTabMenu);
        tabPopupMenu.add(jSeparator22);

        removeTabMenu.setText("Rename Tab");
        removeTabMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                removeTabMenuActionPerformed(evt);
            }
        });
        tabPopupMenu.add(removeTabMenu);

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("Arare SQL Launcher");
        addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                formMouseReleased(evt);
            }
        });
        addWindowListener(new java.awt.event.WindowAdapter() {
            public void windowClosing(java.awt.event.WindowEvent evt) {
                formWindowClosing(evt);
            }
        });

        jPanel1.setLayout(new java.awt.BorderLayout());

        jSplitPane1.setOneTouchExpandable(true);

        jTabbedPane1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseClicked(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseClicked(evt);
            }
        });
        jTabbedPane1.addMouseMotionListener(new java.awt.event.MouseMotionAdapter() {
            public void mouseDragged(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseDragged(evt);
            }
            public void mouseMoved(java.awt.event.MouseEvent evt) {
                jTabbedPane1MouseMoved(evt);
            }
        });
        jTabbedPane1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                jTabbedPane1FocusGained(evt);
            }
        });
        jTabbedPane1.setComponentPopupMenu(this.tabPopupMenu);

        jSplitPane2.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane2.setOneTouchExpandable(true);
        jSplitPane2.setRightComponent(cellBean1);

        editBean1.setFocusCycleRoot(true);
        editBean1.setFont(new java.awt.Font("Arial", 0, 12)); // NOI18N
        editBean1.setName("editBean1"); // NOI18N
        editBean1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                editBean1MouseReleased(evt);
            }
        });
        editBean1.addFocusListener(new java.awt.event.FocusAdapter() {
            public void focusGained(java.awt.event.FocusEvent evt) {
                editBean1FocusGained(evt);
            }
        });
        jSplitPane2.setLeftComponent(editBean1);

        jTabbedPane1.addTab("tab1", jSplitPane2);

        jSplitPane1.setRightComponent(jTabbedPane1);
        jTabbedPane1.getAccessibleContext().setAccessibleName("New tab");

        jSplitPane3.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
        jSplitPane3.setOneTouchExpandable(true);
        jSplitPane3.setLeftComponent(treeBean1);
        jSplitPane3.setRightComponent(cellBean2);
        cellBean2.setJayFrame(this);

        jSplitPane1.setLeftComponent(jSplitPane3);

        jPanel1.add(jSplitPane1, java.awt.BorderLayout.CENTER);

        jPanel2.setLayout(new java.awt.BorderLayout());
        jPanel2.add(messageBean1, java.awt.BorderLayout.CENTER);

        jPanel1.add(jPanel2, java.awt.BorderLayout.PAGE_END);

        getContentPane().add(jPanel1, java.awt.BorderLayout.CENTER);

        jToolBar1.setRollover(true);

        newButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/filenew.png"))); // NOI18N
        newButton.setFocusable(false);
        newButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        newButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        newButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                newButtonMouseEntered(evt);
            }
        });
        newButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                newButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(newButton);

        openButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/fileopen.png"))); // NOI18N
        openButton.setFocusable(false);
        openButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        openButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        openButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                openButtonMouseEntered(evt);
            }
        });
        openButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                openButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(openButton);

        saveButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/filesave.png"))); // NOI18N
        saveButton.setFocusable(false);
        saveButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        saveButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                saveButtonMouseEntered(evt);
            }
        });
        saveButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(saveButton);

        saveAsButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/filesaveas.png"))); // NOI18N
        saveAsButton.setFocusable(false);
        saveAsButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        saveAsButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        saveAsButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                saveAsButtonMouseEntered(evt);
            }
        });
        saveAsButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                saveAsButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(saveAsButton);
        jToolBar1.add(jSeparator1);

        previewButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/preview.png"))); // NOI18N
        previewButton.setFocusable(false);
        previewButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        previewButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        previewButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                previewButtonMouseEntered(evt);
            }
        });
        previewButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                previewButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(previewButton);

        printButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/print.png"))); // NOI18N
        printButton.setFocusable(false);
        printButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        printButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        printButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                printButtonMouseEntered(evt);
            }
        });
        printButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                printButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(printButton);
        jToolBar1.add(jSeparator2);

        cutButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/editcut.png"))); // NOI18N
        cutButton.setFocusable(false);
        cutButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cutButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cutButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                cutButtonMouseEntered(evt);
            }
        });
        cutButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cutButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(cutButton);

        copyButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/editcopy.png"))); // NOI18N
        copyButton.setFocusable(false);
        copyButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        copyButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        copyButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                copyButtonMouseEntered(evt);
            }
        });
        copyButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                copyButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(copyButton);

        pasteButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/editpaste.png"))); // NOI18N
        pasteButton.setFocusable(false);
        pasteButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        pasteButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        pasteButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                pasteButtonMouseEntered(evt);
            }
        });
        pasteButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                pasteButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(pasteButton);
        jToolBar1.add(jSeparator3);

        undoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/undo.png"))); // NOI18N
        undoButton.setFocusable(false);
        undoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        undoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        undoButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                undoButtonMouseEntered(evt);
            }
        });
        undoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                undoButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(undoButton);

        redoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/redo.png"))); // NOI18N
        redoButton.setFocusable(false);
        redoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        redoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        redoButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                redoButtonMouseEntered(evt);
            }
        });
        redoButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                redoButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(redoButton);
        jToolBar1.add(jSeparator4);

        connectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/connect.png"))); // NOI18N
        connectButton.setFocusable(false);
        connectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        connectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        connectButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                connectButtonMouseEntered(evt);
            }
        });
        connectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                connectButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(connectButton);

        disconnectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/disconnect.png"))); // NOI18N
        disconnectButton.setFocusable(false);
        disconnectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        disconnectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        disconnectButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                disconnectButtonMouseEntered(evt);
            }
        });
        disconnectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                disconnectButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(disconnectButton);
        jToolBar1.add(jSeparator16);

        runButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/run.png"))); // NOI18N
        runButton.setFocusable(false);
        runButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        runButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        runButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                runButtonMouseEntered(evt);
            }
        });
        runButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                runButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(runButton);

        viewObjectButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/tree.png"))); // NOI18N
        viewObjectButton.setFocusable(false);
        viewObjectButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        viewObjectButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        viewObjectButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                viewObjectButtonMouseEntered(evt);
            }
        });
        viewObjectButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                viewObjectButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(viewObjectButton);
        jToolBar1.add(jSeparator5);

        commitButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/commit.png"))); // NOI18N
        commitButton.setFocusable(false);
        commitButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        commitButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        commitButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                commitButtonMouseEntered(evt);
            }
        });
        commitButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                commitButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(commitButton);

        rollbackButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/back.png"))); // NOI18N
        rollbackButton.setFocusable(false);
        rollbackButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        rollbackButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        rollbackButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                rollbackButtonMouseEntered(evt);
            }
        });
        rollbackButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                rollbackButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(rollbackButton);
        jToolBar1.add(jSeparator6);

        cancelButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/com/jay/images/stop.png"))); // NOI18N
        cancelButton.setFocusable(false);
        cancelButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        cancelButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        cancelButton.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseEntered(java.awt.event.MouseEvent evt) {
                cancelButtonMouseEntered(evt);
            }
        });
        cancelButton.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                cancelButtonActionPerformed(evt);
            }
        });
        jToolBar1.add(cancelButton);

        getContentPane().add(jToolBar1, java.awt.BorderLayout.PAGE_START);

        FileMenu.setText("File");

        NewFileSubMenu.setText("New");

        NewEmptyTabItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.CTRL_MASK));
        NewEmptyTabItem.setText("New Empty Tab");
        NewEmptyTabItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NewEmptyTabItemActionPerformed(evt);
            }
        });
        NewFileSubMenu.add(NewEmptyTabItem);

        ClearCurrentTabItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_N, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        ClearCurrentTabItem.setText("Clear Current Tab");
        ClearCurrentTabItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ClearCurrentTabItemActionPerformed(evt);
            }
        });
        NewFileSubMenu.add(ClearCurrentTabItem);

        FileMenu.add(NewFileSubMenu);

        OpenFileSubMenu.setText("Open");

        OpenFileIntoNewTabItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        OpenFileIntoNewTabItem.setText("Open file into new tab");
        OpenFileIntoNewTabItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OpenFileIntoNewTabItemActionPerformed(evt);
            }
        });
        OpenFileSubMenu.add(OpenFileIntoNewTabItem);

        OpenFileIntoCurrentTabItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        OpenFileIntoCurrentTabItem.setText("Open file into current tab");
        OpenFileIntoCurrentTabItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                OpenFileIntoCurrentTabItemActionPerformed(evt);
            }
        });
        OpenFileSubMenu.add(OpenFileIntoCurrentTabItem);

        FileMenu.add(OpenFileSubMenu);

        SaveItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        SaveItem.setText("Save");
        SaveItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveItemActionPerformed(evt);
            }
        });
        FileMenu.add(SaveItem);

        SaveAsItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        SaveAsItem.setText("Save as");
        SaveAsItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SaveAsItemActionPerformed(evt);
            }
        });
        FileMenu.add(SaveAsItem);

        CloseTabItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.CTRL_MASK));
        CloseTabItem.setText("Close tab");
        CloseTabItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CloseTabItemActionPerformed(evt);
            }
        });
        FileMenu.add(CloseTabItem);

        CloseAllTabItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        CloseAllTabItem.setText("Close all tab");
        CloseAllTabItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CloseAllTabItemActionPerformed(evt);
            }
        });
        FileMenu.add(CloseAllTabItem);
        FileMenu.add(jSeparator7);

        LoginItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_L, java.awt.event.InputEvent.CTRL_MASK));
        LoginItem.setText("Login");
        LoginItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                LoginItemActionPerformed(evt);
            }
        });
        FileMenu.add(LoginItem);

        DisconnectItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_D, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        DisconnectItem.setText("Disconnect");
        DisconnectItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DisconnectItemActionPerformed(evt);
            }
        });
        FileMenu.add(DisconnectItem);
        FileMenu.add(jSeparator8);

        PreviewSubMenu.setText("Print preview");

        PrintPreviewSQLItem.setText("Print Preview SQL");
        PrintPreviewSQLItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrintPreviewSQLItemActionPerformed(evt);
            }
        });
        PreviewSubMenu.add(PrintPreviewSQLItem);

        PrintPreviewResultItem.setText("Print Preview Result");
        PrintPreviewResultItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrintPreviewResultItemActionPerformed(evt);
            }
        });
        PreviewSubMenu.add(PrintPreviewResultItem);

        FileMenu.add(PreviewSubMenu);

        PrintSubMenu.setText("Print");

        PrintSQLItem.setText("Print SQL");
        PrintSQLItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrintSQLItemActionPerformed(evt);
            }
        });
        PrintSubMenu.add(PrintSQLItem);

        PrintResultItem.setText("Print Result");
        PrintResultItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PrintResultItemActionPerformed(evt);
            }
        });
        PrintSubMenu.add(PrintResultItem);

        FileMenu.add(PrintSubMenu);
        FileMenu.add(jSeparator9);

        ExitItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.ALT_MASK));
        ExitItem.setText("Exit");
        ExitItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExitItemActionPerformed(evt);
            }
        });
        FileMenu.add(ExitItem);

        jMenuBar1.add(FileMenu);

        EditMenu.setText("Edit");

        UndoItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.CTRL_MASK));
        UndoItem.setText("Undo");
        UndoItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                UndoItemActionPerformed(evt);
            }
        });
        EditMenu.add(UndoItem);

        RedoItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_Z, java.awt.event.InputEvent.SHIFT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        RedoItem.setText("Redo");
        RedoItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RedoItemActionPerformed(evt);
            }
        });
        EditMenu.add(RedoItem);
        EditMenu.add(jSeparator10);

        CutItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_X, java.awt.event.InputEvent.CTRL_MASK));
        CutItem.setText("Cut");
        CutItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CutItemActionPerformed(evt);
            }
        });
        EditMenu.add(CutItem);

        CopyItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_C, java.awt.event.InputEvent.CTRL_MASK));
        CopyItem.setText("Copy");
        CopyItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CopyItemActionPerformed(evt);
            }
        });
        EditMenu.add(CopyItem);

        PasteItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_V, java.awt.event.InputEvent.CTRL_MASK));
        PasteItem.setText("Paste");
        PasteItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                PasteItemActionPerformed(evt);
            }
        });
        EditMenu.add(PasteItem);

        SelectAllItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_A, java.awt.event.InputEvent.CTRL_MASK));
        SelectAllItem.setText("Select All");
        SelectAllItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                SelectAllItemActionPerformed(evt);
            }
        });
        EditMenu.add(SelectAllItem);
        EditMenu.add(jSeparator11);

        FindItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));
        FindItem.setText("Find");
        FindItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FindItemActionPerformed(evt);
            }
        });
        EditMenu.add(FindItem);

        FindNextItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
        FindNextItem.setText("Find Next");
        FindNextItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FindNextItemActionPerformed(evt);
            }
        });
        EditMenu.add(FindNextItem);

        ReplaceItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_H, java.awt.event.InputEvent.CTRL_MASK));
        ReplaceItem.setText("Replace");
        ReplaceItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ReplaceItemActionPerformed(evt);
            }
        });
        EditMenu.add(ReplaceItem);
        EditMenu.add(jSeparator12);

        ToggleCaseItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        ToggleCaseItem.setText("Toggle Case Selection");
        ToggleCaseItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ToggleCaseItemActionPerformed(evt);
            }
        });
        EditMenu.add(ToggleCaseItem);

        jMenuBar1.add(EditMenu);

        ScriptMenu.setText("Script");

        RunScriptItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, 0));
        RunScriptItem.setText("Run Script");
        RunScriptItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RunScriptItemActionPerformed(evt);
            }
        });
        ScriptMenu.add(RunScriptItem);

        RunScriptCurrentPositionItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F7, 0));
        RunScriptCurrentPositionItem.setText("Run on statement at current position");
        RunScriptCurrentPositionItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RunScriptCurrentPositionItemActionPerformed(evt);
            }
        });
        ScriptMenu.add(RunScriptCurrentPositionItem);
        ScriptMenu.add(jSeparator14);

        CommitItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F5, java.awt.event.InputEvent.CTRL_MASK));
        CommitItem.setText("Commit");
        CommitItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                CommitItemActionPerformed(evt);
            }
        });
        ScriptMenu.add(CommitItem);

        RollBackItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F6, java.awt.event.InputEvent.CTRL_MASK));
        RollBackItem.setText("Rollback");
        RollBackItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                RollBackItemActionPerformed(evt);
            }
        });
        ScriptMenu.add(RollBackItem);

        jMenuBar1.add(ScriptMenu);

        ResultMenu.setText("Result");
        ResultMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ResultMenuActionPerformed(evt);
            }
        });

        FindInResultItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
        FindInResultItem.setText("Find in Results");
        FindInResultItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                FindInResultItemActionPerformed(evt);
            }
        });
        ResultMenu.add(FindInResultItem);
        ResultMenu.add(jSeparator15);

        ExportToExcelItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.ALT_MASK | java.awt.event.InputEvent.CTRL_MASK));
        ExportToExcelItem.setText("Export results to EXCEL");
        ExportToExcelItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExportToExcelItemActionPerformed(evt);
            }
        });
        ResultMenu.add(ExportToExcelItem);

        ExportToCSVItem.setText("Export results to CSV");
        ExportToCSVItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExportToCSVItemActionPerformed(evt);
            }
        });
        ResultMenu.add(ExportToCSVItem);

        ExportToXMLItem.setText("Export results to XML");
        ExportToXMLItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ExportToXMLItemActionPerformed(evt);
            }
        });
        ResultMenu.add(ExportToXMLItem);

        jMenuBar1.add(ResultMenu);

        ToolsMenu.setText("Tools");
        ToolsMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                ToolsMenuActionPerformed(evt);
            }
        });

        DataImpExpItem.setText("Data Import/Export");
        DataImpExpItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DataImpExpItemActionPerformed(evt);
            }
        });
        ToolsMenu.add(DataImpExpItem);

        DataExpCurrentSQLItem.setText("Data Export for current query");
        DataExpCurrentSQLItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                DataExpCurrentSQLItemActionPerformed(evt);
            }
        });
        ToolsMenu.add(DataExpCurrentSQLItem);

        jMenuBar1.add(ToolsMenu);

        LookAndFeelMenu.setText("Look&Feel");

        NimbusMenu.setText("Nimbus");
        NimbusMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                NimbusMenuActionPerformed(evt);
            }
        });
        LookAndFeelMenu.add(NimbusMenu);

        WindowsMenu.setText("Windows");
        WindowsMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                WindowsMenuActionPerformed(evt);
            }
        });
        LookAndFeelMenu.add(WindowsMenu);

        MetalMenu.setText("Metal");
        MetalMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MetalMenuActionPerformed(evt);
            }
        });
        LookAndFeelMenu.add(MetalMenu);

        MotifMenu.setText("Motif");
        MotifMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MotifMenuActionPerformed(evt);
            }
        });
        LookAndFeelMenu.add(MotifMenu);

        MacMenu.setText("Mac");
        MacMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                MacMenuActionPerformed(evt);
            }
        });
        LookAndFeelMenu.add(MacMenu);

        KunstoffMenu.setText("Kunstoff");
        KunstoffMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                KunstoffMenuActionPerformed(evt);
            }
        });
        LookAndFeelMenu.add(KunstoffMenu);

        jMenuBar1.add(LookAndFeelMenu);

        HelpMenu.setText("Help");
        HelpMenu.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                HelpMenuActionPerformed(evt);
            }
        });

        AboutItem.setText("About");
        AboutItem.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                AboutItemActionPerformed(evt);
            }
        });
        HelpMenu.add(AboutItem);

        jMenuBar1.add(HelpMenu);

        setJMenuBar(jMenuBar1);

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
	 * @param aMap
	 * @param aThisClass
	 */
    public static boolean init(HashMap aMap, Object aThisClass){
        boolean ret = false;
        
        try {
            mExeCuter.setTargetDBInfo(aMap);
            if(mExeCuter.connectToTargetDB()) {
                ret = true;
            }
//			setLnFComboModel();
        } catch (Exception e1) { 
            ed.viewExceptionDialog(e1);
        } 
        return ret;
    }

    private void saveAction(java.awt.event.ActionEvent evt, int aType){
        int iTemp = 0;
        if(this.mOpenFileMap.containsKey(this.jTabbedPane1.getSelectedIndex())){
            iTemp = aType;
        }
        saveAction(iTemp);
    }
    
    public void setFocusEditBean(){
        Component[] comp = this.jSplitPane1.getComponents();
        for(int i=0;i<comp.length;i++){
            System.out.println(comp[i]);
        }
    }
    
    public EditBean getEditBean(){
        return this.editBean1;
    }
    
    private void saveAction(int aType){
        EditBean eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        File f = null;
        switch(aType){
            case 0: //save as
                Frame frame = getFrame();
                JFileChooser chooser = new JFileChooser();
               
                int ret = chooser.showSaveDialog(frame);
                chooser.setDialogTitle(CommonConst.SAVE_AS);
                if (ret != JFileChooser.APPROVE_OPTION) {
                    return;
                }
                f = chooser.getSelectedFile();
                this.jTabbedPane1.setTitleAt(this.jTabbedPane1.getSelectedIndex(), f.getName());
                mOpenFileMap.put(this.jTabbedPane1.getSelectedIndex(), f);
                break;
            case 1: // save
                f = (File)this.mOpenFileMap.get(this.jTabbedPane1.getSelectedIndex());
                break;
            default: // save
                f = (File)this.mOpenFileMap.get(this.jTabbedPane1.getSelectedIndex());
                break;
        }
        
        Thread saver = new FileSaver(f, eb.getDocument(), this);
        saver.start();
    }
    
    private ArrayList newAction(java.awt.event.ActionEvent evt){
        ArrayList ret = new ArrayList();
        
        String aTabName;
        JSplitPane jp = new JSplitPane();
        jp.setOneTouchExpandable(true);
        jp.setOrientation(JSplitPane.VERTICAL_SPLIT);
        EditBean eb = new EditBean();
        CellBean cb = new CellBean();
        eb.setJayFrame(this);
        
        int iTemp = 1;
        try{
            if(this.jTabbedPane1.getComponentCount() > 0){
                iTemp = Integer.parseInt(this.jTabbedPane1.getTitleAt(this.jTabbedPane1.getComponentCount()-1).substring(3))+1;
            }
        }catch(NumberFormatException nfex){
            nfex.printStackTrace();
        }
        aTabName = CommonConst.TAB_STR+(iTemp);
        
        jp.setLeftComponent(eb);
        jp.setRightComponent(cb);
        this.jTabbedPane1.addTab(aTabName, jp);
        this.jTabbedPane1.setSelectedIndex(this.jTabbedPane1.getComponentCount()-1);
        return ret;
    }

    private void openAction(java.awt.event.ActionEvent evt, int aType){
        this.jFileChooser1= new JFileChooser();
        
        int ret = jFileChooser1.showOpenDialog(this);
        
        if (ret != jFileChooser1.APPROVE_OPTION) {
            return;
        }
        File f = jFileChooser1.getSelectedFile();

        int aIndex = 0;
        EditBean eb = null;

        switch(aType){
            case 0: // current tab
                eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
                aIndex = this.jTabbedPane1.getSelectedIndex();
                break;
            case 1: // new tab
                eb = new EditBean();
                eb.setJayFrame(this);
                this.jTabbedPane1.addTab("tab"+(this.jTabbedPane1.getTabCount()+1), eb);
                aIndex = this.jTabbedPane1.getTabCount()-1;
                break;
            default: // current tab
                eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
                aIndex = this.jTabbedPane1.getSelectedIndex();
                break;
        }
        eb.setDocument(new PlainDocument());
        this.jTabbedPane1.setTitleAt(aIndex, f.getName());
        Thread loader = new FileLoader(f, eb.getDocument(), this);
        loader.start();
        mOpenFileMap.put(aIndex, f);
    }

    private void closeTabAction(java.awt.event.ActionEvent evt, int aType){
        if(this.jTabbedPane1.getTabCount()==1){
            return;
        }
        switch(aType){
            case 0: // close current tab
                this.jTabbedPane1.remove(this.jTabbedPane1.getSelectedIndex());
                break;
            case 1: // close all tab
                this.jTabbedPane1.removeAll();
                break;
            default:
                this.jTabbedPane1.remove(this.jTabbedPane1.getSelectedIndex());
                break;
        }
        
        if(this.tabPopupMenu.isVisible())this.tabPopupMenu.setVisible(false);
    }

    private void saveAsButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveAsButtonActionPerformed
        saveAction(evt,0);
}//GEN-LAST:event_saveAsButtonActionPerformed

    private void newButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_newButtonActionPerformed
        // TODO add your handling code here:
        newAction(evt);
}//GEN-LAST:event_newButtonActionPerformed

    void getObjectInfo(String selectedNodeName) {
        jb.setIndeterminate(true);
        GetObjectInfoActionClass task = new GetObjectInfoActionClass(selectedNodeName);
        task.addPropertyChangeListener(this);
        task.execute();
    }

    HashMap getChildObj(String aMomObj) {
        HashMap ret = null;
        aMomObj = aMomObj.substring(0, aMomObj.length()-2);
        ret = chkObj(aMomObj);
        if(ret.size() > 0){
            return ret;
        }else
            return null;
    }

    private HashMap chkObj(String aMomObj) {
        HashMap ret = new HashMap();
//        System.out.println(aMomObj+":"+this.mExeCuter.getTableInfo(aMomObj));
        HashMap aMap = this.mExeCuter.getTableInfo(aMomObj);
        ArrayList aList = (ArrayList)aMap.get(CommonConst.DATUM);
//        System.out.println(aMomObj+":"+CommonConst.DATUM+":"+aList);
        ArrayList aInnerList = null;
        Iterator it = aList.iterator();
        while(it.hasNext()){
            aInnerList = (ArrayList)it.next();
//            System.out.println(aMomObj+":"+CommonConst.DATUM+":InnerList:"+aInnerList);
            ret.put(aInnerList.get(0), aInnerList.get(1));
        }
//        System.out.println(ret);
        return ret;
    }

    ArrayList sortList(ArrayList aList){
        ArrayList ret = new ArrayList();
//        String[] aTempArr = ret.toArray();
        String[] aTempArr = (String[]) aList.toArray(new String[aList.size()]);
        Arrays.sort(aTempArr,  new com.jay.util.StringCompare());
        for(int i=0;i<aTempArr.length;i++){
            ret.add(i, aTempArr[i]);
        }
        
        return ret;
    }
    
    ArrayList getTableAndView(){
        ArrayList ret = new ArrayList();
        HashMap a1stMap = null;
        HashMap a2ndMap = null;
        ArrayList a3rdList = null;
        HashMap a4thMap = null;
        Iterator a1stIt = null;
        Iterator a2ndIt = null;
        Iterator a3rdIt = null;
        try {
            a1stMap = this.mExeCuter.getCatalog();
            a1stIt = a1stMap.keySet().iterator();
            String a1stKey = null;
            String a2ndKey = null;
            String aTempSchema = null;
            while(a1stIt.hasNext()){
                a1stKey = (String)a1stIt.next();
                a2ndMap = (HashMap)a1stMap.get(a1stKey);
                a2ndIt = a2ndMap.keySet().iterator();
                while(a2ndIt.hasNext()){
                    a2ndKey = (String)a2ndIt.next();
                    a3rdList = (ArrayList)a2ndMap.get(a2ndKey);
                    a3rdIt = a3rdList.iterator();
                    while(a3rdIt.hasNext()){
                        a4thMap = (HashMap)a3rdIt.next();
//                        System.out.println(a4thMap);
                        if(CommonConst.MYSQL_TYPE != this.mExeCuter.mTargetDBInfo.mDBType)
                            aTempSchema = a4thMap.get("SCHEME").toString();
                        else
                            aTempSchema = a4thMap.get("CATEGORY").toString();
                        ret.add(aTempSchema+CommonConst.CURRENT_DIR+a4thMap.get("NAME"));
                    }
                }
            }
//            System.out.println(ret);
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
        return sortList(ret);
    }
    
    /**
     * if (aDBType.trim().toUpperCase().equals(DatabaseConnection.ORACLE_STRING))
            mDBType = DatabaseConnection.ORACLE;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.SYBASE_STRING))
            mDBType = DatabaseConnection.SYBASE;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.MSSQLSERVER_STRING))
            mDBType = DatabaseConnection.MSSQLSERVER;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.MYSQL_STRING))
            mDBType = DatabaseConnection.MYSQL;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.TIBERO_STRING))
            mDBType = DatabaseConnection.TIBERO;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.DB2_STRING))
            mDBType = DatabaseConnection.DB2;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.CUBRID_STRING))
            mDBType = DatabaseConnection.CUBRID;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.INFOMIX_STRING))
            mDBType = DatabaseConnection.INFOMIX;
        else if (aDBType.trim().toUpperCase().equals(DatabaseConnection.ALTIBASE_STRING))
            mDBType = DatabaseConnection.ALTIBASE;
        else // default to ORACLE if unknown
            mDBType = DatabaseConnection.ORACLE;
     * @return 
     */

    String getTop10SQL(String aObject) {
        String ret = null;
        switch(this.mExeCuter.mTargetDBInfo.getDBType()){
            case DatabaseConnection.ORACLE:
                ret = "SELECT * FROM "+aObject+" WHERE ROWNUM <= 100";
                break;
            case DatabaseConnection.SYBASE:
                ret = "SELECT TOP 100 * FROM "+aObject;
                break;
            case DatabaseConnection.MSSQLSERVER:
                ret = "SELECT TOP 100 * FROM "+aObject;
                break;
            case DatabaseConnection.MYSQL:
                ret = "SELECT * FROM "+aObject+" LIMIT 100";
                break;
            case DatabaseConnection.TIBERO:
                ret = "SELECT * FROM "+aObject+" WHERE ROWNUM <= 100";
                break;
            case DatabaseConnection.DB2:
                ret = "SELECT * FROM "+aObject+" FETCH FIRST 100 ROWS ONLY";
                break;
            case DatabaseConnection.CUBRID:
                ret = "SELECT * FROM "+aObject+" WHERE ROWNUM <= 100";
                break;
            case DatabaseConnection.INFOMIX:
                ret = "SELECT FIRST 100 * FROM "+aObject;
                break;
            case DatabaseConnection.POSTGRE:
                ret = "SELECT * FROM "+aObject+" LIMIT 100 OFFSET 0";
                break;
            case DatabaseConnection.ALTIBASE:
                ret = "SELECT * FROM "+aObject+" WHERE ROWNUM <= 100";
                break;
            default:
                ret = "SELECT * FROM "+aObject+" WHERE ROWNUM <= 100";
                break;
        }
        return ret;
    }

    class GetObjectInfoActionClass extends SwingWorker{
        String mSelectedNodeName;
        private GetObjectInfoActionClass(String selectedNodeName) {
            this.mSelectedNodeName = selectedNodeName;
        }
        @Override
        public Object doInBackground() throws Exception {
            getObjectInfoAction(mSelectedNodeName);
            return null;
        }
    }

    private void getObjectInfoAction(String selectedNodeName) {
        try {
            DefaultTableModel tableModel = mExeCuter.getTableModel(mExeCuter.getTableInfo(selectedNodeName));
            cellBean2.setModel(tableModel);
        } catch (Exception ex) {
            Logger.getLogger(JayFrame.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
    class ExecuteActionClass extends SwingWorker{
        int exeType = 0;
        private ExecuteActionClass(int exeType) {
            this.exeType = exeType;
        }
        @Override
        public Object doInBackground() throws Exception {
            executeAction(exeType);
            return null;
        }
    }
    
    private void executeAction(int exeType){
        editBean1 = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        
        String aQry = null;
        String aTempStr = null;
        int iCarretPosition = this.editBean1.getEditorPane().getCaretPosition();
        String aRowQry = this.editBean1.getText();
        ArrayList aQryList = this.generateSql(aRowQry);
        String [] aTempStrArr = null;
        
        if(CommonConst.RUN_CURR_POSITON == exeType){
            
            aRowQry = aRowQry.replace(CommonConst.LINE_DELIMTER_N, " ");
            aRowQry = aRowQry.replace(CommonConst.LINE_DELIMTER_R, "");
            aRowQry = aRowQry.replace(CommonConst.TAB, " ");
            aRowQry = aRowQry.trim();
            aTempStr = aRowQry.substring(0, iCarretPosition);
            aTempStrArr = aTempStr.split(CommonConst.SQL_DELIMITER);
            int aTempLength = aTempStrArr.length;                
            aQry = (String)aQryList.get(aTempLength-1);
            aQryList.removeAll(aQryList);
            aQryList.add(aQry);
        }
        executeQryList(aQryList);
    }
    
    private void executeQryList(ArrayList aQryList){
        try {
            //for multiple execute
            Iterator it = aQryList.iterator();
            String aTempExeQry = null;
            do{
                aTempExeQry = (String) it.next();                
                switch(chkSyntax(aTempExeQry)){
                    case CommonConst.DML_SELECT:
                        selectExecuter(aTempExeQry);
                        break;
                    case CommonConst.DML_OTHER:
                        changeExecuter(aTempExeQry);
                        break;
                    case CommonConst.DCL_COMMIT:
                        mExeCuter.commit();                        
                    case CommonConst.DCL_ROLLBACK:
                        mExeCuter.rollback();
                        break;
                    case CommonConst.DDL:
                        changeExecuter(aTempExeQry);
                        break;
                    default:
                        selectExecuter(aTempExeQry);
                        break;
                }
            }while(it.hasNext());
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }
    
    /**
    * @param sQry
    * @param count
    * @return
    */
    private String selectExecuter(String sQry){
        String ret = null;
        try {
            DefaultTableModel tableModel = mExeCuter.getTableModel(sQry);
            CellBean cb = new CellBean();
            cb.setJayFrame(this);
            cb.setModel(tableModel);
            ((JSplitPane)this.jTabbedPane1.getSelectedComponent()).setRightComponent(cb);
        } catch (Exception e) {
            ed.viewExceptionDialog(e);
        }
        return ret;
    }

    /**
        * @param sQry
        * @param count
        * @return
        */
    private int changeExecuter(String sQry){
        int ret = 0;
        try {
            ret = mExeCuter.setDatum(sQry);
        } catch (Exception e) {
            // TODO Auto-generated catch block
            ed.viewExceptionDialog(e);
        }
        return ret;
    }

    private int chkSyntax(String sQry) {
        int sQryType = CommonConst.DML_SELECT;
        sQry = sQry.toUpperCase();
        if(sQry.startsWith(CommonConst.SQL_KEYWORD_COMMIT)){
            sQryType = CommonConst.DCL_COMMIT;
        }else if(sQry.startsWith(CommonConst.SQL_KEYWORD_ROLLBACK)){
            sQryType = CommonConst.DCL_ROLLBACK;
        }else if(sQry.startsWith(CommonConst.SQL_KEYWORD_SELECT)||sQry.startsWith(CommonConst.SQL_KEYWORD_SHOW)){
            sQryType = CommonConst.DML_SELECT;
        }else if(sQry.startsWith(CommonConst.SQL_KEYWORD_INSERT)||
                sQry.startsWith(CommonConst.SQL_KEYWORD_UPDATE)||
                sQry.startsWith(CommonConst.SQL_KEYWORD_DELETE)){
            sQryType = CommonConst.DML_OTHER;
        }else if(sQry.startsWith(CommonConst.SQL_KEYWORD_CREATE)||
                sQry.startsWith(CommonConst.SQL_KEYWORD_GRANT)||
                sQry.startsWith(CommonConst.SQL_KEYWORD_ALTER)||
                sQry.startsWith(CommonConst.SQL_KEYWORD_TRUNCATE)||
                sQry.startsWith(CommonConst.SQL_KEYWORD_DROP)){
            sQryType = CommonConst.DDL;
        }else{
            try {
                throw new Exception("\""+sQry+"\" is Invalid SQL Text");
            } catch (Exception e) {
                // TODO Auto-generated catch block
                ed.viewExceptionDialog(e);
            }
        }
        return sQryType;
    }
    
    
    private ArrayList generateSql(String aQry){
        String ret = aQry;
    //    System.out.println(ret);
        ret = ret.trim();
        ArrayList aQryList = new ArrayList();
        StringTokenizer st = new StringTokenizer(ret, CommonConst.SQL_DELIMITER);
        String aTemp;
        while(st.hasMoreElements()){
            aTemp = ((String)st.nextElement()).trim();
            if(aTemp.length()>0){
                aQryList.add(aTemp);
            }
        }
        return aQryList;
    }

    private void runButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_runButtonActionPerformed
        jb.setIndeterminate(true);
        ExecuteActionClass task = new ExecuteActionClass(CommonConst.RUN_SCRIPT);
        task.addPropertyChangeListener(this);
        task.execute();
}//GEN-LAST:event_runButtonActionPerformed
    
    private void cutAction(java.awt.event.ActionEvent evt){
        editBean1 = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        editBean1.cut();
    }

    private void cutButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cutButtonActionPerformed
        // TODO add your handling code here:
        cutAction(evt);
}//GEN-LAST:event_cutButtonActionPerformed
    
    private void pasteAction(java.awt.event.ActionEvent ev){
        editBean1 = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        editBean1.paste();
    }

    private void pasteButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteButtonActionPerformed
       this.pasteAction(evt);
}//GEN-LAST:event_pasteButtonActionPerformed
    
    private void copyAction(java.awt.event.ActionEvent evt){
        editBean1 = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        editBean1.copy();
    }

    private void copyButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyButtonActionPerformed
        // TODO add your handling code here:
        this.copyAction(evt);
}//GEN-LAST:event_copyButtonActionPerformed

    private void openButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_openButtonActionPerformed
        // TODO add your handling code here:
        openAction(evt, 0);
}//GEN-LAST:event_openButtonActionPerformed

    private void saveButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_saveButtonActionPerformed
        // TODO add your handling code here:
        saveAction(evt, 1);
}//GEN-LAST:event_saveButtonActionPerformed

    private void undoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undoButtonActionPerformed
        // TODO add your handling code here:
        this.undoAction();
    }//GEN-LAST:event_undoButtonActionPerformed

    private void redoButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redoButtonActionPerformed
        // TODO add your handling code here:
        this.redoAction();
       
    }//GEN-LAST:event_redoButtonActionPerformed

    private void undoAction(){
        if (um.canUndo()){
            um.undo();
        } else {
            warn("Can't unod");
        }
    }

    private void redoAction(){
         if (um.canRedo()) {
          um.redo();
        } else {
          warn("Can't redo");
        }
    }

    protected void warn(String msg) {
        JOptionPane.showMessageDialog(this, "Warning: " + msg, "Warning", JOptionPane.WARNING_MESSAGE);
    }
  
    protected void info(String msg) {
        showObject();
        JOptionPane.showMessageDialog(this, "Infomation: " + msg, "Information", JOptionPane.INFORMATION_MESSAGE);
        cdb = null;        
    }

    class CommitActionClass extends SwingWorker{
        @Override
        public Object doInBackground() throws Exception {
            commitAction();
            return null;
        }
    }
  
    private void commitAction(){
        try {
            // TODO add your handling code here:
            this.mExeCuter.commit();
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }

    private void commitButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_commitButtonActionPerformed
        jb.setIndeterminate(true);
        CommitActionClass task = new CommitActionClass();
        task.addPropertyChangeListener(this);
        task.execute();
    }//GEN-LAST:event_commitButtonActionPerformed

    class RollbackActionClass extends SwingWorker{
        @Override
        public Object doInBackground() throws Exception {
            rollbackAction();
            return null;
        }
    }
    
    private void rollbackAction(){
        try {
            // TODO add your handling code here:
            mExeCuter.rollback();
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }

    private void rollbackButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_rollbackButtonActionPerformed
        jb.setIndeterminate(true);
        RollbackActionClass task = new RollbackActionClass();
        task.addPropertyChangeListener(this);
        task.execute();
    }//GEN-LAST:event_rollbackButtonActionPerformed

    private void cancelButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed
        try {
            // TODO add your handling code here:
            if(this.mExeCuter.mDBUtil.mActionStatement != null
                    && !(this.mExeCuter.mDBUtil.mActionStatement.isClosed())){
                this.mExeCuter.cancelExecute();
            }
        } catch (SQLException ex) {
            ed.viewExceptionDialog(ex);
        }
}//GEN-LAST:event_cancelButtonActionPerformed

    private void printButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_printButtonActionPerformed
        // TODO add your handling code here:
        EditBean eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        eb.printText();
    }//GEN-LAST:event_printButtonActionPerformed

    private void previewButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_previewButtonActionPerformed
        // TODO add your handling code here:
        previewAction(evt, CommonConst.PREVIEW_RESULT);
}//GEN-LAST:event_previewButtonActionPerformed

    private void previewAction(java.awt.event.ActionEvent evt, int aType){
        final PrintPreview pp = new PrintPreview();
        
        EditBean eb = null;
        switch(aType){
            case 0:
                eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
                eb.setEditable(false);
                pp.showPreview(eb.getEditorPane());
                break;
            case 1:
                JTable jt = ((JTable)getCellBean().getJTable());
                pp.showPreview(jt);
                break;
            default:
                eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
                eb.setEditable(false);
                pp.showPreview(eb.getEditorPane());
                break;
        }
    }
    
    private void connectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_connectButtonActionPerformed
        try {
            // TODO add your handling code here:
            if(mExeCuter.getTargetDBConnection()!=null && mExeCuter.getTargetDBConnection().isConnectionAlive())
                info(CommonConst.CONNECTED);
            else
                this.showConnectDialog();
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
}//GEN-LAST:event_connectButtonActionPerformed

    private void clearObj(){
        this.editBean1.clear();
        this.treeBean1.clear();
        for(int i=0; i<this.jTabbedPane1.getComponentCount();i++){
            ((EditBean)((JSplitPane)this.jTabbedPane1.getComponent(i)).getLeftComponent()).clear();
            ((CellBean)((JSplitPane)this.jTabbedPane1.getComponent(i)).getRightComponent()).clear();
        }
        this.cellBean1.clear();
        this.cellBean2.clear();
    }
    
    private void disconnectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_disconnectButtonActionPerformed
        try {
            // TODO add your handling code here:
            this.mExeCuter.getTargetDBConnection().disconnect();
            this.warn(CommonConst.DISCONNECTED);
            this.clearObj();
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }//GEN-LAST:event_disconnectButtonActionPerformed

    private void NewEmptyTabItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NewEmptyTabItemActionPerformed
        // TODO add your handling code here:
        
        newAction(evt);
}//GEN-LAST:event_NewEmptyTabItemActionPerformed

    private void ClearCurrentTabItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ClearCurrentTabItemActionPerformed
        // TODO add your handling code here:
        EditBean eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        eb.clear();
}//GEN-LAST:event_ClearCurrentTabItemActionPerformed

    private void OpenFileIntoNewTabItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OpenFileIntoNewTabItemActionPerformed
        // TODO add your handling code here:
        openAction(evt, 1);
}//GEN-LAST:event_OpenFileIntoNewTabItemActionPerformed

    private void OpenFileIntoCurrentTabItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_OpenFileIntoCurrentTabItemActionPerformed
        // TODO add your handling code here:
        openAction(evt, 0);
}//GEN-LAST:event_OpenFileIntoCurrentTabItemActionPerformed

    private void CloseTabItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CloseTabItemActionPerformed
        // TODO add your handling code here:
        closeTabAction(evt,0);
}//GEN-LAST:event_CloseTabItemActionPerformed

    private void CloseAllTabItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CloseAllTabItemActionPerformed
        // TODO add your handling code here:
        closeTabAction(evt,1);
}//GEN-LAST:event_CloseAllTabItemActionPerformed

    private void LoginItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_LoginItemActionPerformed
        // TODO add your handling code here:
        this.showConnectDialog();
}//GEN-LAST:event_LoginItemActionPerformed

    private void DisconnectItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DisconnectItemActionPerformed
        try {
            // TODO add your handling code here:
            this.mExeCuter.getTargetDBConnection().disconnect();
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
}//GEN-LAST:event_DisconnectItemActionPerformed

    private void ExitItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExitItemActionPerformed
        // TODO add your handling code here:
        
        if(this.um.canRedo()){
            if(JOptionPane.showConfirmDialog(this, "Are you save ?", "Save ?", JOptionPane.QUESTION_MESSAGE) == 0){
                this.saveAction(evt, 1);
            };
        }
        System.exit(0);
}//GEN-LAST:event_ExitItemActionPerformed

    private void formWindowClosing(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_formWindowClosing
        // TODO add your handling code here:
        if(this.um.canRedo()){
            if(JOptionPane.showConfirmDialog(this, "Are you save ?", "Save ?", JOptionPane.QUESTION_MESSAGE) == 0){
                this.saveAction(1);
            };
        }
    }//GEN-LAST:event_formWindowClosing

    private void showObject(){
        jb.setIndeterminate(true);
        GetCatalogAction task = new GetCatalogAction();
        task.addPropertyChangeListener(this);
        task.execute();        
    }
    
    private void viewObjectButtonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_viewObjectButtonActionPerformed
        // TODO add your handling code here:
        showObject();
}//GEN-LAST:event_viewObjectButtonActionPerformed

    private void newButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_newButtonMouseEntered
        // TODO add your handling code here:
        this.newButton.setToolTipText("New Empty Tab");
    }//GEN-LAST:event_newButtonMouseEntered

    private void openButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_openButtonMouseEntered
        // TODO add your handling code here:
        this.openButton.setToolTipText("Open into current tab");
    }//GEN-LAST:event_openButtonMouseEntered

    private void saveButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveButtonMouseEntered
        // TODO add your handling code here:
        this.saveButton.setToolTipText("Save");
    }//GEN-LAST:event_saveButtonMouseEntered

    private void saveAsButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_saveAsButtonMouseEntered
        // TODO add your handling code here:
        this.saveAsButton.setToolTipText("Save as");
    }//GEN-LAST:event_saveAsButtonMouseEntered

    private void previewButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_previewButtonMouseEntered
        // TODO add your handling code here:
        this.previewButton.setToolTipText("Preview Result");
}//GEN-LAST:event_previewButtonMouseEntered

    private void printButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_printButtonMouseEntered
        // TODO add your handling code here:
        this.printButton.setToolTipText("Print SQL");
    }//GEN-LAST:event_printButtonMouseEntered

    private void cutButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cutButtonMouseEntered
        // TODO add your handling code here:
        this.cutButton.setToolTipText("Cut");
    }//GEN-LAST:event_cutButtonMouseEntered

    private void copyButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_copyButtonMouseEntered
        // TODO add your handling code here:
        this.copyButton.setToolTipText("Copy");
    }//GEN-LAST:event_copyButtonMouseEntered

    private void pasteButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_pasteButtonMouseEntered
        // TODO add your handling code here:
        this.pasteButton.setToolTipText("Paste");
    }//GEN-LAST:event_pasteButtonMouseEntered

    private void undoButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_undoButtonMouseEntered
        // TODO add your handling code here:
        this.undoButton.setToolTipText("Undo");
    }//GEN-LAST:event_undoButtonMouseEntered

    private void redoButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_redoButtonMouseEntered
        // TODO add your handling code here:
        this.redoButton.setToolTipText("Redo");
    }//GEN-LAST:event_redoButtonMouseEntered

    private void connectButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_connectButtonMouseEntered
        // TODO add your handling code here:
        this.connectButton.setToolTipText("Connect");
    }//GEN-LAST:event_connectButtonMouseEntered

    private void disconnectButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_disconnectButtonMouseEntered
        // TODO add your handling code here:
        this.disconnectButton.setToolTipText("Disconnect");
    }//GEN-LAST:event_disconnectButtonMouseEntered

    private void runButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_runButtonMouseEntered
        // TODO add your handling code here:
        this.runButton.setToolTipText("Run Script");
    }//GEN-LAST:event_runButtonMouseEntered

    private void viewObjectButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_viewObjectButtonMouseEntered
        // TODO add your handling code here:
        this.viewObjectButton.setToolTipText("View / Refresh Object");
    }//GEN-LAST:event_viewObjectButtonMouseEntered

    private void commitButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_commitButtonMouseEntered
        // TODO add your handling code here:
        this.commitButton.setToolTipText("Commit");
    }//GEN-LAST:event_commitButtonMouseEntered

    private void rollbackButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_rollbackButtonMouseEntered
        // TODO add your handling code here:
        this.rollbackButton.setToolTipText("Rollback");
    }//GEN-LAST:event_rollbackButtonMouseEntered

    private void cancelButtonMouseEntered(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_cancelButtonMouseEntered
        // TODO add your handling code here:
        this.cancelButton.setToolTipText("Cancel");
    }//GEN-LAST:event_cancelButtonMouseEntered

    private void PrintSQLItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrintSQLItemActionPerformed
        EditBean eb = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent());
        eb.printText();
}//GEN-LAST:event_PrintSQLItemActionPerformed

    private void PrintResultItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrintResultItemActionPerformed
        try {
            getCellBean().printTable();
        } catch (PrinterException ex) {
            ed.viewExceptionDialog(ex);
        }
}//GEN-LAST:event_PrintResultItemActionPerformed

    private void SaveItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveItemActionPerformed
        saveAction(evt, 1);
}//GEN-LAST:event_SaveItemActionPerformed

    private void CutItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CutItemActionPerformed
        this.cutAction(evt);
}//GEN-LAST:event_CutItemActionPerformed

    private void CopyItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CopyItemActionPerformed
        this.copyAction(evt);
}//GEN-LAST:event_CopyItemActionPerformed

    private void PasteItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PasteItemActionPerformed
        this.pasteAction(evt);
}//GEN-LAST:event_PasteItemActionPerformed

    private void RunScriptItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RunScriptItemActionPerformed
        jb.setIndeterminate(true);
        ExecuteActionClass task = new ExecuteActionClass(CommonConst.RUN_SCRIPT);
        task.addPropertyChangeListener(this);
        task.execute();
}//GEN-LAST:event_RunScriptItemActionPerformed

    private void CommitItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_CommitItemActionPerformed
        // TODO add your handling code here:
        jb.setIndeterminate(true);
        CommitActionClass task = new CommitActionClass();
        task.addPropertyChangeListener(this);
        task.execute();
}//GEN-LAST:event_CommitItemActionPerformed

    private void RollBackItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RollBackItemActionPerformed
        // TODO add your handling code here:
        jb.setIndeterminate(true);
        RollbackActionClass task = new RollbackActionClass();
        task.addPropertyChangeListener(this);
        task.execute();
}//GEN-LAST:event_RollBackItemActionPerformed

    private void UndoItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_UndoItemActionPerformed
        // TODO add your handling code here:
        this.undoAction();
}//GEN-LAST:event_UndoItemActionPerformed

    private void SaveAsItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SaveAsItemActionPerformed
        // TODO add your handling code here:
        saveAction(evt, 0);
    }//GEN-LAST:event_SaveAsItemActionPerformed

    private void PrintPreviewSQLItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrintPreviewSQLItemActionPerformed
        // TODO add your handling code here:
        previewAction(evt, 0);
    }//GEN-LAST:event_PrintPreviewSQLItemActionPerformed

    private void PrintPreviewResultItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_PrintPreviewResultItemActionPerformed
        // TODO add your handling code here:
         previewAction(evt, 1);
    }//GEN-LAST:event_PrintPreviewResultItemActionPerformed

    private void RedoItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RedoItemActionPerformed
        // TODO add your handling code here:
        this.redoAction();
    }//GEN-LAST:event_RedoItemActionPerformed

    private void ToggleCaseItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ToggleCaseItemActionPerformed
        // TODO add your handling code here:
        toggleCaseSelectionAction();
    }//GEN-LAST:event_ToggleCaseItemActionPerformed

    private void FindItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FindItemActionPerformed
        // TODO add your handling code here:
        this.showSearchDialog(CommonConst.FIND);
    }//GEN-LAST:event_FindItemActionPerformed

    private void ReplaceItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ReplaceItemActionPerformed
        // TODO add your handling code here:
        this.showSearchDialog(CommonConst.REPLACE);
    }//GEN-LAST:event_ReplaceItemActionPerformed

    private void FindNextItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FindNextItemActionPerformed
        // TODO add your handling code here:
        findNextItemAction();
    }//GEN-LAST:event_FindNextItemActionPerformed

    private void RunScriptCurrentPositionItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_RunScriptCurrentPositionItemActionPerformed
        jb.setIndeterminate(true);
        ExecuteActionClass task = new ExecuteActionClass(CommonConst.RUN_CURR_POSITON);
        task.addPropertyChangeListener(this);
        task.execute();
    }//GEN-LAST:event_RunScriptCurrentPositionItemActionPerformed

    private void ResultMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ResultMenuActionPerformed
        // TODO add your handling code here:
        this.showSearchDialog(CommonConst.FIND_IN_RESULT);
    }//GEN-LAST:event_ResultMenuActionPerformed

    private void ExportToExcelItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExportToExcelItemActionPerformed
        // TODO add your handling code here:
        exportToExcel();
    }//GEN-LAST:event_ExportToExcelItemActionPerformed

    private void ExportToCSVItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExportToCSVItemActionPerformed
        // TODO add your handling code here:
        exportToCSV();
    }//GEN-LAST:event_ExportToCSVItemActionPerformed

    private void ExportToXMLItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ExportToXMLItemActionPerformed
        // TODO add your handling code here:
        exportToXML();
    }//GEN-LAST:event_ExportToXMLItemActionPerformed

    private void ToolsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_ToolsMenuActionPerformed
        // TODO add your handling code here:        
    }//GEN-LAST:event_ToolsMenuActionPerformed

    private void DataExpCurrentSQLItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DataExpCurrentSQLItemActionPerformed
        // TODO add your handling code here:
        exportForCurrentSQL();
    }//GEN-LAST:event_DataExpCurrentSQLItemActionPerformed

    private void DataImpExpItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_DataImpExpItemActionPerformed
        // TODO add your handling code here:
        showDumpHandler();
    }//GEN-LAST:event_DataImpExpItemActionPerformed

    private void MetalMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MetalMenuActionPerformed
        // TODO add your handling code here:
        changeLookAndFeel(CommonLnFConst.METAL_LNF);
    }//GEN-LAST:event_MetalMenuActionPerformed

    private void MotifMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MotifMenuActionPerformed
        // TODO add your handling code here:
        changeLookAndFeel(CommonLnFConst.MOTIF_LNF);
    }//GEN-LAST:event_MotifMenuActionPerformed

    private void MacMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_MacMenuActionPerformed
        // TODO add your handling code here:
        changeLookAndFeel(CommonLnFConst.MACOS_LNF);
    }//GEN-LAST:event_MacMenuActionPerformed

    private void KunstoffMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_KunstoffMenuActionPerformed
        // TODO add your handling code here:
        changeLookAndFeel(CommonLnFConst.KUNSTSOF_LNF);
    }//GEN-LAST:event_KunstoffMenuActionPerformed

    private void FindInResultItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_FindInResultItemActionPerformed
        // TODO add your handling code here:
        this.showSearchDialog(CommonConst.FIND_IN_RESULT);
    }//GEN-LAST:event_FindInResultItemActionPerformed

private void HelpMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_HelpMenuActionPerformed
// TODO add your handling code here:    
}//GEN-LAST:event_HelpMenuActionPerformed

private void AboutItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_AboutItemActionPerformed
// TODO add your handling code here:
    this.showAboutDialog();
}//GEN-LAST:event_AboutItemActionPerformed

private void closeTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_closeTabMenuActionPerformed
// TODO add your handling code here:
    closeTabAction(evt,0);
}//GEN-LAST:event_closeTabMenuActionPerformed

private void undoTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_undoTabMenuActionPerformed
// TODO add your handling code here:
    this.undoAction();
}//GEN-LAST:event_undoTabMenuActionPerformed

private void redoTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_redoTabMenuActionPerformed
// TODO add your handling code here:
    this.redoAction();
}//GEN-LAST:event_redoTabMenuActionPerformed

private void cutTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cutTabMenuActionPerformed
// TODO add your handling code here:
    this.cutAction(evt);
}//GEN-LAST:event_cutTabMenuActionPerformed

private void copyTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_copyTabMenuActionPerformed
// TODO add your handling code here:
    this.copyAction(evt);
}//GEN-LAST:event_copyTabMenuActionPerformed

private void pasteTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_pasteTabMenuActionPerformed
// TODO add your handling code here:
    this.pasteAction(evt);
}//GEN-LAST:event_pasteTabMenuActionPerformed

private void selectAllTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_selectAllTabMenuActionPerformed
// TODO add your handling code here:
    this.selectAllAction(evt);
}//GEN-LAST:event_selectAllTabMenuActionPerformed

private void SelectAllItemActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_SelectAllItemActionPerformed
// TODO add your handling code here:
    this.selectAllAction(evt);
}//GEN-LAST:event_SelectAllItemActionPerformed

private void findTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findTabMenuActionPerformed
// TODO add your handling code here:
    this.showSearchDialog(CommonConst.FIND);
}//GEN-LAST:event_findTabMenuActionPerformed

private void findTabNextMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_findTabNextMenuActionPerformed
// TODO add your handling code here:
}//GEN-LAST:event_findTabNextMenuActionPerformed

private void replaceTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_replaceTabMenuActionPerformed
// TODO add your handling code here:
     this.showSearchDialog(CommonConst.REPLACE);
}//GEN-LAST:event_replaceTabMenuActionPerformed

private void toggleCaseTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_toggleCaseTabMenuActionPerformed
// TODO add your handling code here:
    toggleCaseSelectionAction();
}//GEN-LAST:event_toggleCaseTabMenuActionPerformed

private void removeTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_removeTabMenuActionPerformed
// TODO add your handling code here:
    renameTabAction(evt);
}//GEN-LAST:event_removeTabMenuActionPerformed

private void commentOutTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_commentOutTabMenuActionPerformed
// TODO add your handling code here:
    commentOutAction(evt);
}//GEN-LAST:event_commentOutTabMenuActionPerformed

private void uncommentTabMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_uncommentTabMenuActionPerformed
// TODO add your handling code here:
    uncommentAction(evt);
}//GEN-LAST:event_uncommentTabMenuActionPerformed

    private void formMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_formMouseReleased
        // TODO add your handling code here:
    }//GEN-LAST:event_formMouseReleased

    private void NimbusMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_NimbusMenuActionPerformed
        // TODO add your handling code here:
        changeLookAndFeel(CommonLnFConst.NiMBUS_LNF);
    }//GEN-LAST:event_NimbusMenuActionPerformed

    private void WindowsMenuActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_WindowsMenuActionPerformed
        // TODO add your handling code here:
        changeLookAndFeel(CommonLnFConst.WINDOWS_LNF);
    }//GEN-LAST:event_WindowsMenuActionPerformed

    private void jTabbedPane1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_jTabbedPane1FocusGained
        ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent()).setFocusable(true);

    }//GEN-LAST:event_jTabbedPane1FocusGained

    private void jTabbedPane1MouseClicked(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseClicked
        // TODO add your handling code here:
    }//GEN-LAST:event_jTabbedPane1MouseClicked

    private void editBean1FocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_editBean1FocusGained

    }//GEN-LAST:event_editBean1FocusGained

    private void editBean1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_editBean1MouseReleased
        // TODO add your handling code here:

    }//GEN-LAST:event_editBean1MouseReleased

    private void jTabbedPane1MouseDragged(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseDragged
        // TODO add your handling code here:
    }//GEN-LAST:event_jTabbedPane1MouseDragged

    private void jTabbedPane1MouseMoved(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jTabbedPane1MouseMoved
        // TODO add your handling code here:
    }//GEN-LAST:event_jTabbedPane1MouseMoved

    private void toggleCaseSelectionAction() {
        String ret = this.editBean1.getEditorPane().getSelectedText();
        String aTemp = new String();
        if(ret !=null){
            aTemp = ret.toUpperCase();
            if(aTemp.equals(ret)){
                ret = ret.toLowerCase();
            }else ret = aTemp;
            ((JEditorPane)editBean1.getEditorPane()).replaceSelection(ret);
        }
    }

    private void findNextItemAction() {
        ed.viewExceptionDialog(new UnsupportedOperationException("Not yet implemented"));
    }

    private void findInResultAction() {
        ed.viewExceptionDialog(new UnsupportedOperationException("Not yet implemented"));
    }

    private void exportToExcel() {
        try {
            if(cu.export2SpreadSheet(getCellBean().getJTable(), CommonUtil.getCurrentTime(CommonConst.DATETIME_FORMAT), this)){
                JOptionPane.showMessageDialog(this, "Infomation: " + CommonConst.SUCCESS_SAVE, "Information", JOptionPane.INFORMATION_MESSAGE);                
            }
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }

    private void exportToCSV() {
        try {
            if(cu.export2CSV(getCellBean().getJTable(), this)){
                JOptionPane.showMessageDialog(this, "Infomation: " + CommonConst.SUCCESS_SAVE, "Information", JOptionPane.INFORMATION_MESSAGE);                
            }
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }

    private void exportToXML() {
        try {
            if(cu.export2XML(getCellBean().getJTable(), this)){
                JOptionPane.showMessageDialog(this, "Infomation: " + CommonConst.SUCCESS_SAVE, "Information", JOptionPane.INFORMATION_MESSAGE);                
            }
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }

    private void showDumpHandler() {
        ed.viewExceptionDialog(new UnsupportedOperationException("Not yet implemented"));
    }

    private void exportForCurrentSQL() {
        ed.viewExceptionDialog(new UnsupportedOperationException("Not yet implemented"));
    }

    private void changeLookAndFeel(String aLNF) {
        try {
            UIManager.setLookAndFeel(aLNF);            
            SwingUtilities.updateComponentTreeUI(this);
            MessageBean.setLabel(aLNF);
            this.pack();
            this.setSize(this.getPreferredSize());
        } catch (Exception ex) {
            ed.viewExceptionDialog(ex);
        }
    }
    
    /**
     * @param aTheme
     * @throws Exception
     */
//    private void changeTheme(String aTheme){
//        try {
//            Field aField = CommonThemeConst.class.getField(aTheme);
//	    String aThemePack = (aField.get(aTheme)).toString();
//            Skin theSkinToUse = SkinLookAndFeel.loadThemePack(CommonConst.LIB_DIR + File.separator + aThemePack);
//            SkinLookAndFeel.setSkin(theSkinToUse);
//            changeLookAndFeel(CommonConst.SKIN_LNF);
//        } catch (Exception ex) {
//            Logger.getLogger(JayFrame.class.getName()).log(Level.SEVERE, null, ex);
//            ed.viewExceptionDialog(ex);
//        }
//    }
    
//    private void setThemeComboModel(){
//        CommonThemeConst aArg = new CommonThemeConst();
//        mComboModel = mExeCuter.getConstComboBoxModel(aArg);
//        this.jComboBox1.setModel(mComboModel);
//        this.jComboBox1.setPreferredSize(this.jComboBox1.getPreferredSize());
//    }

    public CellBean getCellBean() {
        CellBean ret = (CellBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getRightComponent();
        return ret;
    }

    private void showAboutDialog() {
        AboutDialogBean adb = new AboutDialogBean(this);
        adb.setLocationRelativeTo(this);
        adb.setModal(true);
        adb.setVisible(true);
    }

    private int getVisibleTabNo(){
        int ret = 0;
        for(int i=0;i<this.jTabbedPane1.getTabCount();i++){
            if(this.jTabbedPane1.getComponentAt(i).isShowing()){
                ret = i;
                break;
            }
        }
        return ret;
    }
    
    private void selectAllAction(ActionEvent evt) {
        JEditorPane jep = ((EditBean)((JSplitPane)this.jTabbedPane1.getSelectedComponent()).getLeftComponent()).getEditorPane();
        jep.requestFocus();
        jep.selectAll();
    }

    private void renameTabAction(ActionEvent evt) {
        CommonInputDialogBean cid = new CommonInputDialogBean(this, true);
        cid.setLocationRelativeTo(this);
        cid.setVisible(true);
        this.jTabbedPane1.setTitleAt(getVisibleTabNo(),this.mCommonInput);
    }

    private void blockIndentAction(ActionEvent evt) {
        ed.viewExceptionDialog(new UnsupportedOperationException("Not yet implemented"));
    }

    private void blockUnindentAction(ActionEvent evt) {
        ed.viewExceptionDialog(new UnsupportedOperationException("Not yet implemented"));
    }

    private void commentOutAction(ActionEvent evt) {
        JEditorPane jp = editBean1.getEditorPane();
        int tempStart = jp.getSelectionStart();
        
        for(int i=tempStart;i>0;i--){
            try {
                if(jp.getText(i,1).matches("\\s")){
                    tempStart = i;
                    break;
                }
            } catch (BadLocationException ex) {
                Logger.getLogger(JayFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        int tempEnd = jp.getSelectionEnd();
        jp.select(tempStart, tempEnd);
        
        String beforeText = jp.getSelectedText();
        String afterText = "";
        
        beforeText = jp.getSelectedText();
        afterText += beforeText.replaceAll("\\s",System.getProperty("line.separator")+"//");
        
        jp.replaceSelection(afterText);        
    }

    private void uncommentAction(ActionEvent evt) {
        JEditorPane jp = editBean1.getEditorPane();
        
        int tempStart = jp.getSelectionStart();
        
        for(int i=tempStart;i>0;i--){
            try {
                if(jp.getText(i,1).matches("\\s")){
                    tempStart = i;
                    break;
                }
            } catch (BadLocationException ex) {
                Logger.getLogger(JayFrame.class.getName()).log(Level.SEVERE, null, ex);
            }
        }
        
        int tempEnd = jp.getSelectionEnd();

        jp.select(tempStart, tempEnd);
        
        String beforeText = jp.getSelectedText();
        String afterText = "";
        
        afterText += beforeText.replaceAll("//","");
        
        jp.replaceSelection(afterText);        
    }

    public void propertyChange(PropertyChangeEvent evt) {
        if(SwingWorker.StateValue.DONE.equals(evt.getNewValue()))
            this.messageBean1.getJProgressBar().setIndeterminate(false); 
        MessageBean.setLabel(evt.getNewValue().toString());
    }

    public void actionPerformed(ActionEvent e) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    
    class GetCatalogAction extends SwingWorker{
        @Override
        public Object doInBackground() throws Exception {
            DatabaseConnection conn = mExeCuter.getTargetDBConnection();
//            treeBean1.setModel(mExeCuter.getCatalog(),  conn.dbTypeToString()+"("+conn.getUsername()+"@"+conn.getHostName()+")");
            return treeBean1.setModel(mExeCuter.getCatalog(),  conn.dbTypeToString()+"("+conn.getUsername()+"@"+conn.getHostName()+")");
        }
    }

    public MessageBean getMessageBean(){
        return this.messageBean1;
    }
    
    protected Frame getFrame() {
        for (Container p = getParent(); p != null; p = p.getParent()) {
            if (p instanceof Frame) {
                return (Frame) p;
            }
        }
        return null;
    }

    public void showConnectDialog(){
        cdb = new ConnectDialogBean(this);
        cdb.setLocationRelativeTo(this);
        cdb.setModal(true);
        cdb.setVisible(true);
    }
    
    public void showSearchDialog(int aType){
        SRFrame srp = new SRFrame(this, aType);
        srp.setLocationRelativeTo(this);
        srp.setModalExclusionType(Dialog.ModalExclusionType.APPLICATION_EXCLUDE);
        srp.setVisible(true);
    }
    
    /**
    * @param args the command line arguments
    */
    public static void main(String args[]) {
        java.awt.EventQueue.invokeLater(new Runnable() {
            public void run() {
                try {
                    UIManager.setLookAndFeel(UIManager.getCrossPlatformLookAndFeelClassName());
                    for (LookAndFeelInfo info : UIManager.getInstalledLookAndFeels()) {
                        if ("Nimbus".equals(info.getName())) {
                            UIManager.setLookAndFeel(info.getClassName());
                            break;
                        }
                    } 
                } catch (Exception ex) {
                    ed.viewExceptionDialog(ex);
                }
         
                JayFrame jf = new JayFrame();
                jf.setExtendedState(java.awt.Frame.MAXIMIZED_BOTH);
                jf.showConnectDialog();                
            }
        });
    }

    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JMenuItem AboutItem;
    private javax.swing.JMenuItem ClearCurrentTabItem;
    private javax.swing.JMenuItem CloseAllTabItem;
    private javax.swing.JMenuItem CloseTabItem;
    private javax.swing.JMenuItem CommitItem;
    private javax.swing.JMenuItem CopyItem;
    private javax.swing.JMenuItem CutItem;
    private javax.swing.JMenuItem DataExpCurrentSQLItem;
    private javax.swing.JMenuItem DataImpExpItem;
    private javax.swing.JMenuItem DisconnectItem;
    private javax.swing.JMenu EditMenu;
    private javax.swing.JMenuItem ExitItem;
    private javax.swing.JMenuItem ExportToCSVItem;
    private javax.swing.JMenuItem ExportToExcelItem;
    private javax.swing.JMenuItem ExportToXMLItem;
    private javax.swing.JMenu FileMenu;
    private javax.swing.JMenuItem FindInResultItem;
    private javax.swing.JMenuItem FindItem;
    private javax.swing.JMenuItem FindNextItem;
    private javax.swing.JMenu HelpMenu;
    private javax.swing.JMenuItem KunstoffMenu;
    private javax.swing.JMenuItem LoginItem;
    private javax.swing.JMenu LookAndFeelMenu;
    private javax.swing.JMenuItem MacMenu;
    private javax.swing.JMenuItem MetalMenu;
    private javax.swing.JMenuItem MotifMenu;
    private javax.swing.JMenuItem NewEmptyTabItem;
    private javax.swing.JMenu NewFileSubMenu;
    private javax.swing.JMenuItem NimbusMenu;
    private javax.swing.JMenuItem OpenFileIntoCurrentTabItem;
    private javax.swing.JMenuItem OpenFileIntoNewTabItem;
    private javax.swing.JMenu OpenFileSubMenu;
    private javax.swing.JMenuItem PasteItem;
    private javax.swing.JMenu PreviewSubMenu;
    private javax.swing.JMenuItem PrintPreviewResultItem;
    private javax.swing.JMenuItem PrintPreviewSQLItem;
    private javax.swing.JMenuItem PrintResultItem;
    private javax.swing.JMenuItem PrintSQLItem;
    private javax.swing.JMenu PrintSubMenu;
    private javax.swing.JMenuItem RedoItem;
    private javax.swing.JMenuItem ReplaceItem;
    private javax.swing.JMenu ResultMenu;
    private javax.swing.JMenuItem RollBackItem;
    private javax.swing.JMenuItem RunScriptCurrentPositionItem;
    private javax.swing.JMenuItem RunScriptItem;
    private javax.swing.JMenuItem SaveAsItem;
    private javax.swing.JMenuItem SaveItem;
    private javax.swing.JMenu ScriptMenu;
    private javax.swing.JMenuItem SelectAllItem;
    private javax.swing.JMenuItem ToggleCaseItem;
    private javax.swing.JMenu ToolsMenu;
    private javax.swing.JMenuItem UndoItem;
    private javax.swing.JMenuItem WindowsMenu;
    private javax.swing.JButton cancelButton;
    private com.jay.gui.CellBean cellBean1;
    private com.jay.gui.CellBean cellBean2;
    private javax.swing.JMenuItem closeTabMenu;
    private javax.swing.JMenuItem commentOutTabMenu;
    private javax.swing.JButton commitButton;
    private javax.swing.JButton connectButton;
    private javax.swing.JButton copyButton;
    private javax.swing.JMenuItem copyTabMenu;
    private javax.swing.JButton cutButton;
    private javax.swing.JMenuItem cutTabMenu;
    private javax.swing.JButton disconnectButton;
    private com.jay.gui.EditBean editBean1;
    private javax.swing.JMenuItem findTabMenu;
    private javax.swing.JMenuItem findTabNextMenu;
    private javax.swing.JFileChooser jFileChooser1;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JToolBar.Separator jSeparator1;
    private javax.swing.JSeparator jSeparator10;
    private javax.swing.JSeparator jSeparator11;
    private javax.swing.JSeparator jSeparator12;
    private javax.swing.JPopupMenu.Separator jSeparator13;
    private javax.swing.JSeparator jSeparator14;
    private javax.swing.JSeparator jSeparator15;
    private javax.swing.JToolBar.Separator jSeparator16;
    private javax.swing.JPopupMenu.Separator jSeparator17;
    private javax.swing.JPopupMenu.Separator jSeparator18;
    private javax.swing.JToolBar.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator20;
    private javax.swing.JPopupMenu.Separator jSeparator21;
    private javax.swing.JPopupMenu.Separator jSeparator22;
    private javax.swing.JToolBar.Separator jSeparator3;
    private javax.swing.JToolBar.Separator jSeparator4;
    private javax.swing.JToolBar.Separator jSeparator5;
    private javax.swing.JToolBar.Separator jSeparator6;
    private javax.swing.JSeparator jSeparator7;
    private javax.swing.JSeparator jSeparator8;
    private javax.swing.JSeparator jSeparator9;
    private javax.swing.JSplitPane jSplitPane1;
    private javax.swing.JSplitPane jSplitPane2;
    private javax.swing.JSplitPane jSplitPane3;
    private javax.swing.JTabbedPane jTabbedPane1;
    private javax.swing.JToolBar jToolBar1;
    private com.jay.gui.MessageBean messageBean1;
    private javax.swing.JButton newButton;
    private javax.swing.JButton openButton;
    private javax.swing.JButton pasteButton;
    private javax.swing.JMenuItem pasteTabMenu;
    private javax.swing.JButton previewButton;
    private javax.swing.JButton printButton;
    private javax.swing.JButton redoButton;
    private javax.swing.JMenuItem redoTabMenu;
    private javax.swing.JMenuItem removeTabMenu;
    private javax.swing.JMenuItem replaceTabMenu;
    private javax.swing.JButton rollbackButton;
    private javax.swing.JButton runButton;
    private javax.swing.JButton saveAsButton;
    private javax.swing.JButton saveButton;
    private javax.swing.JMenuItem selectAllTabMenu;
    private javax.swing.JPopupMenu tabPopupMenu;
    private javax.swing.JMenuItem toggleCaseTabMenu;
    private com.jay.gui.TreeBean treeBean1;
    private javax.swing.JMenuItem uncommentTabMenu;
    private javax.swing.JButton undoButton;
    private javax.swing.JMenuItem undoTabMenu;
    private javax.swing.JButton viewObjectButton;
    // End of variables declaration//GEN-END:variables
    static Executer mExeCuter = new Executer();
    
    public static ExceptionDialog ed = null;

    /** UndoManager that we add edits to. */
    protected UndoManager um;

    private HashMap  mOpenFileMap = new HashMap();
}